﻿using DevExpress.XtraBars.Ribbon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace simpleHotel.Client.Common
{
    public class Common
    {
        private static int _hotelID = -1;
        /// <summary>
        /// Current hotel id
        /// </summary>
        public static int HotelID 
        {
            get { return _hotelID; }
            set { _hotelID = value; }
        }

        private static string _userName = string.Empty;
        /// <summary>
        /// Current username
        /// </summary>
        public static string UserName
        {
            get { return _userName; }
            set { _userName = value; }
        }

        public static string AdminRole = "admin";
        public static string HotelRole = "hotel";
        
        
        public static ProcessController NewProcessingDialog()
        {

            ProcessController tk = new ProcessController();
            Thread t = NewThread();
            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(string message)
        {

            ProcessController tk = new ProcessController();
            Thread t = NewThread(message);

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(RibbonForm father)
        {
            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread();

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(RibbonForm father, string message)
        {
            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread(message);

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseForm father)
        {


            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread();

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseForm father, string message)
        {


            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread(message);

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseRibbonForm father)
        {


            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = new Thread((obj) =>
            {

                ProcessDialog f2 = new ProcessDialog((ProcessController)obj);
                f2.ShowDialog();

            });

            t.Start(tk);
            return tk;
        }

        public static ProcessController NewProcessingDialog(BaseRibbonForm father, string message)
        {
            ProcessController tk = new ProcessController(father.Location, father.Size);
            Thread t = NewThread(message);
            t.Start(tk);

            return tk;
        }

        private static Thread NewThread(string message)
        {
            Thread t = new Thread((obj) =>
            {
                ProcessDialog f2 = new ProcessDialog((ProcessController)obj);
                f2.ShowDialog();
            });
            return t;
        }

        private static Thread NewThread()
        {
            Thread t = new Thread((obj) =>
            {
                ProcessDialog f2 = new ProcessDialog((ProcessController)obj);
                f2.ShowDialog();
            });
            return t;
        }
    }
}
